﻿using LY.Entity.PageSearch;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LY.Entity;
using LY.Entity.SearchEntity;
namespace LY.DataAccess.Repository
{
    public class ProjectItemRepository : BaseRepository
    {
        //查询收货列表
        public PagedList<R_ProjectItem> GetProjectItemList(int id, PageView view)
        {
            string cols = @"[Id]
                          ,[ProjectId]
                          ,[Amount]
                          ,[MRedoundContent]
                          ,[RedoundType]
                          ,[RedoundContent]
                          ,[RedoundImage]
                          ,[Limits]
                          ,[Freight]
                          ,[DedoundDays]
                          ,[Createtime]";
            string sqlWhere = " and ProjectId=" + id;
            return base.PageGet<R_ProjectItem>(view, cols, @" [R_ProjectItem] ", sqlWhere, "[Id] ASC", "");
        }

        public R_ProjectItem GetProjectItem(int? id)
        {
            string sql = @"SELECT [Id]
                          ,[ProjectId]
                          ,[Amount]
                          ,[MRedoundContent]
                          ,[RedoundType]
                          ,[RedoundContent]
                          ,[RedoundImage]
                          ,[Limits]
                          ,[Freight]
                          ,[DedoundDays]
                          ,[Createtime]
                      FROM [R_ProjectItem] where Id=@ID";
            return base.Get<R_ProjectItem>(sql, new { ID = id });
        }

        //根据主键ID删除绑定
        public int DeleteProjectItem(int id)
        {
            string sql = "delete from R_ProjectItem where Id=@ID";
            return base.Excute(sql, new { ID = id });
        }
        //根据项目id删除回报
        public int DeleteItemByProID(int id)
        {
            String sql = "delete from R_ProjectItem where ProjectId=@ProjectId";
            return base.Excute(sql, new { ProjectId = id });
        }
    }
}
